<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    337. House Robber III
   </h1>
   <p>
    The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a binary tree". It will automatically contact the police if two directly-linked houses were broken into on the same night.
   </p>
   <p>
    Determine the maximum amount of money the thief can rob tonight without alerting the police.
   </p>
   <p>
    <b>
     Example 1:
    </b>
   </p>
   <pre>
<strong>Input: </strong>[3,2,3,null,3,null,1]

     <font color="red">3</font>
    / \
   2   3
    \   \ 
     <font color="red">3   1
</font>
<strong>Output:</strong> 7 
<strong>Explanation:</strong>&nbsp;Maximum amount of money the thief can rob = <font color="red" style='font-family: sans-serif, Arial, Verdana, "Trebuchet MS";'>3</font><span style='font-family: sans-serif, Arial, Verdana, "Trebuchet MS";'> + </span><font color="red" style='font-family: sans-serif, Arial, Verdana, "Trebuchet MS";'>3</font><span style='font-family: sans-serif, Arial, Verdana, "Trebuchet MS";'> + </span><font color="red" style='font-family: sans-serif, Arial, Verdana, "Trebuchet MS";'>1</font><span style='font-family: sans-serif, Arial, Verdana, "Trebuchet MS";'> = </span><b style='font-family: sans-serif, Arial, Verdana, "Trebuchet MS";'>7</b><span style='font-family: sans-serif, Arial, Verdana, "Trebuchet MS";'>.</span></pre>
   <p>
    <b>
     Example 2:
    </b>
   </p>
   <pre>
<strong>Input: </strong>[3,4,5,1,3,null,1]

&nbsp;    3
    / \
   <font color="red">4</font>   <font color="red">5</font>
  / \   \ 
 1   3   1

<strong>Output:</strong> 9
<strong>Explanation:</strong>&nbsp;Maximum amount of money the thief can rob = <font color="red">4</font> + <font color="red">5</font> = <b>9</b>.
</pre>
  </div>
  <div>
   <h1 class="question_title">
    337. 打家劫舍 III
   </h1>
   <p>
    在上次打劫完一条街道之后和一圈房屋后，小偷又发现了一个新的可行窃的地区。这个地区只有一个入口，我们称之为&ldquo;根&rdquo;。 除了&ldquo;根&rdquo;之外，每栋房子有且只有一个&ldquo;父&ldquo;房子与之相连。一番侦察之后，聪明的小偷意识到&ldquo;这个地方的所有房屋的排列类似于一棵二叉树&rdquo;。 如果两个直接相连的房子在同一天晚上被打劫，房屋将自动报警。
   </p>
   <p>
    计算在不触动警报的情况下，小偷一晚能够盗取的最高金额。
   </p>
   <p>
    <strong>
     示例 1:
    </strong>
   </p>
   <pre><strong>输入: </strong>[3,2,3,null,3,null,1]

     <strong>3</strong>
    / \
   2   3
    \   \ 
     <strong>3</strong>   <strong>1</strong>

<strong>输出:</strong> 7 
<strong>解释:</strong>&nbsp;小偷一晚能够盗取的最高金额 = 3 + 3 + 1 = <strong>7</strong>.</pre>
   <p>
    <strong>
     示例 2:
    </strong>
   </p>
   <pre><strong>输入: </strong>[3,4,5,1,3,null,1]

&nbsp;    3
    / \
   <strong>4</strong>   <strong>5</strong>
  / \   \ 
 1   3   1

<strong>输出:</strong> 9
<strong>解释:</strong>&nbsp;小偷一晚能够盗取的最高金额&nbsp;= <strong>4</strong> + <strong>5</strong> = <strong>9</strong>.
</pre>
  </div>
 </body>
</html>